//
//  XLHTTPClent.m
//  Car4S
//
//  Created by William Zheng on 13-4-19.
//
//

#import "XLHTTPClent.h"
#import "AFJSONRequestOperation.h"
#import "AFURLConnectionOperation.h"
#import "AFNetworkActivityIndicatorManager.h"
#import "XLConfig.h"

static NSString *domain;

@implementation XLHTTPClent
+ (XLHTTPClent *)sharedClient
{
    static XLHTTPClent *_instance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [[XLHTTPClent alloc] initWithBaseURL:[NSURL URLWithString:[self domain]]];
    });
    return _instance;
}

+ (NSString *)domain
{
    return [XLConfig domain];
}

- (id)initWithBaseURL:(NSURL *)url {
    self = [super initWithBaseURL:url];
    if (!self) {
        return nil;
    }
    [AFNetworkActivityIndicatorManager sharedManager].enabled = YES;
    if ([[url scheme] isEqualToString:@"https"] && [[url host] isEqualToString:@"alpha-api.app.net"]) {
        [self setDefaultSSLPinningMode:AFSSLPinningModePublicKey];
    }
    return self;
}
@end
